Skip to content

Conversation

@chippison
Copy link
Contributor

Description

Dev-19785

This PR is to fix the regression we had when we tried to redirect invalid session errors to login page (https://innocraft.atlassian.net/browse/UX-305).

We only want to force the redirect when we actually detect an invalid session issue and not to redirect ALL NoAccessExceptions. We will retain the original behaviour of NoAccessException for ajax calls to just fail silently and just returning the error message.

Testing:

NOTE: The only way I could test this fix was to try to do some datatable actions that will trigger saving of table preference. This would show errors and will refresh the page with no change in the sorting when the issue is not fixed. This happened when the regression was introduced and was noticeable on our Demo Site.
If the issue is fixed, the datatable should not give any errors and sorting should work (although it will not be saved because it is 'anonymous' user).

This should still error and redirect if a session becomes invalid (session expires or is deleted). I was able to test this by logging in as an admin to my local site. Then deleted my session (or changing the expire date to something in the past), then clicking on a new category/page or even just trying to sort the datatable.

Checklist

  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules

Review

@chippison chippison requested a review from a team December 23, 2025 03:46
@chippison chippison marked this pull request as ready for review December 23, 2025 03:46
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Jan 7, 2026
@chippison chippison added the Do not close PRs with this label won't be marked as stale by the Close Stale Issues action label Jan 7, 2026
@sgiehl sgiehl removed Do not close PRs with this label won't be marked as stale by the Close Stale Issues action Stale The label used by the Close Stale Issues action labels Jan 15, 2026
@sgiehl sgiehl force-pushed the fix-ajax-no-access-error branch from b8ea408 to b795c1a Compare January 15, 2026 08:27
@sgiehl sgiehl added the Regression Indicates a feature used to work in a certain way but it no longer does even though it should. label Jan 15, 2026
@sgiehl sgiehl added this to the 5.7.0 milestone Jan 15, 2026
sgiehl

This comment was marked as outdated.

@chippison
Copy link
Contributor Author

Generally the changes might work, but are far away from "perfect". When working on such legacy parts it's important to also challenge the current implementation and consider fundamental changes instead of just relying on existing behavior.

I've used codex to create some code upon your changes, to implement a proper session timeout handling that is less error prone and improve the code overall a bit:

  • Relying on 401 status code might still cause problems, as plugins might send 401 status codes, that should not result in reloads. I've update that to use a custom header instead.
  • Setting a global Access state when the session has a real timeout makes the whole handling a lot more accurate, than trying to detect that based on the referrer.
  • As the more accurate timeout detection would prevent the session timeout message to be displayed after page reload this state is temporarily stored in a cookie
  • Properly differ between 401 (fully unauthorized requests) and 403 (authorized requests without permission)

See fix-ajax-no-access-error...fix-session-timeout-handling for the proposed changes.

Note: This was built upon my rough ideas. I haven't done a proper review or deeper testing yet

Thanks for your input on this @sgiehl.
It was really helpful to point me in the right direction.
I have merged your changes(fix-session-timeout-handling) to this PR.
I also added some code to make it work if anonymous users are allowed to view the site.
Hopefully my changes are all good. 😁

Cheers

@chippison chippison requested a review from sgiehl January 16, 2026 02:58
sgiehl

This comment was marked as outdated.

@sgiehl sgiehl force-pushed the fix-ajax-no-access-error branch 3 times, most recently from 345e17b to ebc08c1 Compare January 20, 2026 09:04
@sgiehl sgiehl force-pushed the fix-ajax-no-access-error branch from ebc08c1 to 07714c8 Compare January 20, 2026 09:57
@sgiehl sgiehl requested a review from a team January 20, 2026 11:57
@sgiehl sgiehl dismissed their stale review January 20, 2026 11:57

outdated

@sgiehl sgiehl added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.

Development

Successfully merging this pull request may close these issues.

3 participants